//-----------------------------------------------------------------------
// <copyright file="ResponsibleService.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using MyFramework;
using MIMS.WRS.Entities;
using MIMS.WRS.Data;
    
namespace MIMS.WRS.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class ResponsibleService
    {
		public static ResponsibleCollection GetResponsiblesByConPoint(int conPointID)
		{            
			try
			{
				ResponsibleDAO responsibleDAO = new ResponsibleDAO();
				return responsibleDAO.GetResponsiblesByConPoint(conPointID);
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetResponsiblesException, ex);
			}
		}     

        #region Responsible

        public static void CreateResponsible(Responsible responsible)
        {            
            try
            {
                ResponsibleDAO responsibleDAO = new ResponsibleDAO();
                responsibleDAO.CreateResponsible(responsible);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateResponsibleException, ex);
            }
        }        

        public static void UpdateResponsible(Responsible responsible)
        {            
            try
            {
                ResponsibleDAO responsibleDAO = new ResponsibleDAO();
                responsibleDAO.UpdateResponsible(responsible);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateResponsibleException, ex);
            }
        }        

        public static void DeleteResponsible(int responsibleID)
        {            
            try
            {
                ResponsibleDAO responsibleDAO = new ResponsibleDAO();
                responsibleDAO.DeleteResponsible(responsibleID);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteResponsibleException, ex);
            }
        }
        
        public static Responsible GetResponsible(int responsibleID)
        {            
            try
            {
                ResponsibleDAO responsibleDAO = new ResponsibleDAO();
                return responsibleDAO.GetResponsible(responsibleID);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetResponsibleException, ex);
            }
        }                

        public static ResponsibleCollection GetResponsibles(ResponsibleColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                ResponsibleDAO responsibleDAO = new ResponsibleDAO();
                return responsibleDAO.GetResponsibles(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetResponsiblesException, ex);
            }
        }        

        public static ResponsibleCollection GetResponsibles(ResponsibleColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                ResponsibleDAO responsibleDAO = new ResponsibleDAO();
                return responsibleDAO.GetResponsibles(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetResponsiblesException, ex);
            }
        }        

        #endregion
    }
}